import Vue from "vue";
import Vuex from "vuex";
import Config from "../config/config";        //基础配置--API接口域名等
import MapApi  from  '../config/MapApiConfig';   //集成所有的 api 路径接口地址

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: '',      //token 密钥
    user_data:{},     //用户信息；目前主要两个字段：user_name、 user_real_name
    domain_url: Config.serverURL,
    uploadimg: Config.uploadFile,
    mapapi: MapApi,
    navMap:[],              //根据用户权限，左侧可展示的导航栏列表
    buttonPermission: {},     //按钮权限
    navList:[],
    nav_titleList: [                          //  顶部分级展示栏   首页/**/
      {
        title: "首页",
        path: "/"
      }
    ],
    showNavList: [
      // 展示点击导航
      {
        title: "首页",
        path: "/",
        edit: true,
        class: ["nav-Toview-item"],
        class1: ["activeColor", "nav-Toview-item"],
        index: 0
      }
    ],   
    openedsList:['1'],      // 默认展开菜单     
  },
  mutations: {      //修改 state中的值
       /**
        * 
        * @param {*} state 
        * @param {object} parameters 
        * 例如修改指定  {a:1}
        */
       changeState(state,parameters){
         if(parameters&&typeof parameters ==="object"){
             Object.keys(parameters).forEach((v,k)=>{
                      state[v]=parameters[v]
             })

         }
         else{
                      throw "参数不能为空";     
         }    
       }
  },
  actions: {
  },
  modules: {}
});